<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>


<script type="text/javascript">
	function serviceAgreementSelector_afterSelected(rows) {
		var ids = rows[0].id;
		for ( var i = 1; i < rows.length; i++) {
			var item = rows[i];
			ids = ids + "," + item.id;
		}

		 $.post("slm/projectAgreement/saveAgreements", {
			projectId : '${projectId}',
			AgreementIds : ids
		}, function(data) {
			serviceAgreementGrid.reload();//刷新已选
		}); 
	}
</script>
<isperp:listSelector id="serviceAgreementSelector" showClearBtn="false"
		displayValueCssClass="hidden" selectorCssClass="hidden"
		showPager="false"
		url="slm/serviceAgreement/list"
		afterSelected="serviceAgreementSelector_afterSelected(rows);"
		multiselect="true">
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<isperp:column name="name" title="名称" width="100">
		</isperp:column>

	</isperp:listSelector>
<isperp:grid
	url="slm/serviceAgreement/listDetail?projectId=${projectId }"
	gridId="serviceAgreementGrid" gridTitle="${pageTitle}"
	cusDialogSize="normal"
	ondbClickRowEvent="serviceAgreementGrid.edit(rowid);"
	showSearchbar="false" multiselect="false" showPager="false"
	cusDeleteUrl="slm/projectAgreement/delete" idFieldName="relate_id"
	beforeCreateAction="'projectId=${projectId }'">
	<jsp:attribute name="toolbar">	
	<isperp:toolbar id="serviceAgreementToolbar">
	    <isperp:button id="serviceAgreementCreate" icon="icon-plus"
				text="选择服务协议" onclick="$('#serviceAgreementSelector').click();"></isperp:button>
	</isperp:toolbar>
	</jsp:attribute>
	<jsp:body>
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<isperp:column name="relate_id" title="relate_id" hidden="true"></isperp:column>
		<isperp:column name="name" title="名称" width="100">
		</isperp:column>
		<isperp:column name="slm_type"  title="类型" width="50">
		</isperp:column>
		<isperp:column name="goal"   title="合规性目标(%)" width="80">
		</isperp:column>
		<isperp:column name="use_project_calendar"    title="服务响应" width="80"
			isFormatterFun="true"
			formatter="if(cellvalue==1)return '项目日历';return '7*24服务';">
		</isperp:column>
		<isperp:column name="service_way" title="服务方式"   width="80">
		</isperp:column>

		<isperp:column name="slm_status"   title="状态" width="80">
		</isperp:column>	

	</jsp:body>
</isperp:grid>
